Skip to content

docs: document the empty state of the no-argument constructor - #4

Merged
javier-godoy merged 2 commits into
masterfrom
issue-3
Sep 1, 2026
Merged

docs: document the empty state of the no-argument constructor#4
javier-godoy merged 2 commits into
masterfrom
issue-3

Conversation

@paodb

@paodb paodb commented Aug 31, 2026

Copy link
Copy Markdown
Member

docs: document the empty state of the no-argument constructor

new RelativeTime() renders nothing until setDateTime is called, which read as a broken component on first use. The behavior was only mentioned in SPECIFICATIONS.md, and the constructor Javadoc just said "Creates an empty component".

PR includes the following documentation updates:

  • RelativeTime: add an "Empty state" paragraph to the class Javadoc, and expand the no-argument constructor Javadoc with when to use it (component renderers, asynchronously loaded data, displays that start empty) and why no default is applied.
  • README: add a "Components without a value yet" section to the Developer Guide, with grid-renderer and value-change-listener examples.
  • SPECIFICATIONS: align §3.1 and §4 with the same explanation.
  • UseCasesDemo: state in the stopwatch description that it is built with the no-argument constructor and renders nothing until Start.

Close #3

Summary by CodeRabbit

  • Documentation
    • Clarified that RelativeTime can be created without an initial date and remains empty until a date is provided.
    • Documented deferred initialization for asynchronous data loading and reusable grid renderers.
    • Explained that calling clear() returns the component to its empty state.
    • Updated usage examples, including stopwatch behavior when starting and stopping.

@paodb
paodb marked this pull request as ready for review August 31, 2026 19:44

@javier-godoy javier-godoy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shift from defensive language (e.g. "not a failure", "intentional, not a failure: [...] deliberately" ) to direct, authoritative behavior documentation.

Comment thread README.md Outdated

### Components without a value yet

`new RelativeTime()` writes no `datetime` attribute, so **it renders nothing** until `setDateTime` is called. This is intentional, not a failure: there is deliberately no default value, because defaulting to the current instant would display a time that is not the intended one, and would keep ticking away from it until the real value arrived.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider a rewrite:

  1. Clear & Technical

new RelativeTime() intentionally renders nothing until setDateTime() is called. Omitting a default datetime attribute prevents displaying an incorrect initial timestamp that drifts out of sync while awaiting the actual value.

  1. Direct & Punchy

By design, new RelativeTime() stays empty on instantiation until setDateTime() runs. Defaulting to the current time would show inaccurate data that continuously ticks away from the intended target until the true value arrives.

  1. Concise (Single-Sentence)

new RelativeTime() deliberately renders nothing until setDateTime() is invoked to prevent showing a temporary default timestamp that drifts further out of sync before the real data arrives.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took option 1, with two changes. Dropped "intentionally", since option 3's "deliberately" is the same register the review flags. And kept "writes no datetime attribute", because that's the concrete thing a reader can check in the DOM, and all three options dropped it.

Result: "new RelativeTime() writes no datetime attribute and renders nothing until setDateTime is called. No default is applied: the current instant would be a value the caller did not choose, and it would keep ticking away from the intended one until that value arrives."

Comment on lines +102 to +110
/**
* Creates a component with no target datetime: nothing is rendered until {@link #setDateTime} is
* called. Use it when the value is not available at construction time, such as in component
* renderers ({@code new ComponentRenderer<>(RelativeTime::new, (rt, item) -> ...)}),
* asynchronously loaded data, or displays that start empty and are reset with {@link #clear()}.
*
* <p>No default is applied on purpose: defaulting to the current instant would display a time
* other than the intended one, and would keep ticking away from it.
*/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/**
* Creates a component with no target datetime: nothing is rendered until {@link #setDateTime} is
* called. Use it when the value is not available at construction time, such as in component
* renderers ({@code new ComponentRenderer<>(RelativeTime::new, (rt, item) -> ...)}),
* asynchronously loaded data, or displays that start empty and are reset with {@link #clear()}.
*
* <p>No default is applied on purpose: defaulting to the current instant would display a time
* other than the intended one, and would keep ticking away from it.
*/
/**
* Creates a relative time component without a target datetime. Renders nothing until
* {@link #setDateTime} is called.
*
* <p>Use this constructor when the datetime is unavailable at creation, such as in
* component renderers ({@code new ComponentRenderer<>(RelativeTime::new, ...)}),
* asynchronous data loading, or views reset via {@link #clear()}.
*/

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied, with one addition. I kept a short paragraph on why there is no default, because that rationale is what issue #3 was about, and without it in the code the question comes back the next time someone reads the constructor. Reworded in the direct voice:

"No default datetime is applied. The current instant would be a value the caller did not choose, and it would keep ticking away from the intended one until that value arrives."

Also changed "views reset via clear()" to "displays", since clear() resets the component, not a view.

Comment on lines +52 to +55
* <p><b>Empty state.</b> A component with no target datetime renders nothing at all: the
* underlying element has no text to show. This is the documented behaviour of the
* {@linkplain #RelativeTime() no-argument constructor} and of {@link #clear()}, not a failure; see
* that constructor for when an empty component is the right starting point.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* <p><b>Empty state.</b> A component with no target datetime renders nothing at all: the
* underlying element has no text to show. This is the documented behaviour of the
* {@linkplain #RelativeTime() no-argument constructor} and of {@link #clear()}, not a failure; see
* that constructor for when an empty component is the right starting point.
* <p><b>Empty state.</b> When no target datetime is configured, this component renders blank.
* This is intentional for both the {@linkplain #RelativeTime() no-argument constructor} and {@link #clear()}.
* See the constructor Javadoc for applicable use cases.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied.

@github-project-automation github-project-automation Bot moved this from To Do to In Progress in Flowing Code Addons Sep 1, 2026
@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: b4ba800d-baba-4eab-9d61-76de6cf04ee9

📥 Commits

Reviewing files that changed from the base of the PR and between e524ada and 39e029b.

📒 Files selected for processing (4)
  • README.md
  • SPECIFICATIONS.md
  • src/main/java/com/flowingcode/vaadin/addons/relativetime/RelativeTime.java
  • src/test/java/com/flowingcode/vaadin/addons/relativetime/UseCasesDemo.java

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


Walkthrough

The changes document the empty state of RelativeTime() across the README, specification, Javadoc, and stopwatch demo. They state that rendering starts after setDateTime() and returns to empty after clear().

Changes

RelativeTime empty-state behavior

Layer / File(s) Summary
Empty-state contract and usage documentation
README.md, SPECIFICATIONS.md, src/main/java/.../RelativeTime.java, src/test/java/.../UseCasesDemo.java
Documentation describes no-datetime rendering, deferred initialization, the absence of a default datetime, and reset behavior through clear(). The stopwatch example reflects the same lifecycle.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk: ⚪ Minimal · up to 39e02

This documentation-only change clarifies the existing empty-state behavior and adds usage examples; no actionable merge-blocking risk remains.

Suggested reviewers: scardanzan

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (2 skipped: 2… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: documenting the empty state of the no-argument constructor.
Linked Issues check ✅ Passed The PR documents the empty rendering behavior of RelativeTime(), including README guidance and constructor Javadoc, as required by issue #3. The documentation also covers setDateTime(), clear(), defer…
Out of Scope Changes check ✅ Passed All changes are documentation updates related to issue #3. The README, specification, RelativeTime Javadoc, and UseCasesDemo changes consistently explain the no-datetime empty state.
Full details: Linked Issues check

Explanation

The PR documents the empty rendering behavior of RelativeTime(), including README guidance and constructor Javadoc, as required by issue #3. The documentation also covers setDateTime(), clear(), deferred data, and renderer use cases.

Full details: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-3

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@paodb

paodb commented Sep 1, 2026

Copy link
Copy Markdown
Member Author

Agreed. The wording was arguing against the issue instead of documenting the behavior. Removed "not a failure", "intentional" and "deliberately" from all four places: the two you flagged, plus SPECIFICATIONS.md §4, which carried the same phrasing.

@paodb
paodb requested a review from javier-godoy September 1, 2026 13:18
@javier-godoy
javier-godoy merged commit fc4d593 into master Sep 1, 2026
3 of 4 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Pending release in Flowing Code Addons Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Pending release

Development

Successfully merging this pull request may close these issues.

Should the no-parameter constructor default to Instant.now()?

2 participants